<template>
    <div>
        <el-table v-loading="listLoading" :data="binList" stripe border fit style="width: 100%; margin-top: 10px">
            <el-table-column label="文件名称" width="300" align="center" prop="fileName">
            </el-table-column>
            <el-table-column label="文件类型" width="200" align="center" prop="type">
            </el-table-column>
            <el-table-column label="文件大小" width="200" align="center" prop="size">
            </el-table-column>
            <el-table-column label="删除时间" width="200" align="center" prop="updateTime">
            </el-table-column>
            <el-table-column label="恢复" align="center" fixed="right">
                <template slot-scope="scope">
                    <el-button type="primary" icon="el-icon-refresh-right" size="mini" @click="recover(scope.row)"
                        title="恢复" />
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
import api from '@/api/system/file'
export default {
    data() {
        return {
            value: true,
            listLoading: false,
            binList: [],
        };
    },
    created() {
        this.fetch()
    },
    methods: {
        fetch() {
            api.getBin().then(response => {
                this.binList = response.data
            })
        },
        recover(file) {
            this.$confirm('此操作将复原该文件, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                file.isDelete = 0
                api.recover(file)
                    .then(response => {
                        //提示
                        this.$message({
                            type: 'success',
                            message: '复原成功!'
                        });
                        //刷新
                        this.fetch()
                    })
            })
        }
    },
}
</script>